import request from '@/utils/request'

export function myUpload(uploadId, demandId, data) {
  return request({
    url: '/autotest/case/upload?uploadId=' + uploadId + '&demandId=' + demandId,
    method: 'post',
    data
  })
}

export function createCase(data) {
  return request({
    url: '/autotest/case/create/case',
    method: 'post',
    data
  })
}

export function createFolder(data) {
  return request({
    url: '/autotest/case/create/folder',
    method: 'post',
    data
  })
}

export function updateCase(data, reason) {
  return request({
    url: '/autotest/case/update/case',
    method: 'post',
    data
  })
}

export function demandCaseTree(demandId, moduleIds, levels) {
  return request({
    url: '/autotest/case/demandCaseTree',
    method: 'get',
    params: { demandId, moduleIds, levels }
  })
}

export function taskCaseTree(taskId, moduleIds, levels) {
  return request({
    url: '/autotest/case/taskCaseTree',
    method: 'get',
    params: { taskId, moduleIds, levels }
  })
}

export function taskCaseTreeMine(taskId, moduleIds, levels) {
  return request({
    url: '/autotest/case/taskCaseTreeMine',
    method: 'get',
    params: { taskId, moduleIds, levels }
  })
}

export function caseTreeTaskParent(taskId, moduleIds, levels) {
  return request({
    url: '/autotest/case/caseTreeTaskParent',
    method: 'get',
    params: { taskId, moduleIds, levels }
  })
}

export function moduleCaseTree(moduleIds) {
  return request({
    url: '/autotest/case/moduleCaseTree',
    method: 'get',
    params: { moduleIds }
  })
}

export function demandAddCaseByIds(demandId, caseIds) {
  return request({
    url: '/autotest/case/demandAddCaseByIds',
    method: 'get',
    params: { demandId, caseIds }
  })
}

export function taskAddCaseByIds(taskId, caseIds) {
  return request({
    url: '/autotest/case/taskAddCaseByIds',
    method: 'get',
    params: { taskId, caseIds }
  })
}

export function demandRemoveCaseByIds(demandId, caseIds) {
  return request({
    url: '/autotest/case/demandRemoveCaseByIds',
    method: 'get',
    params: { demandId, caseIds }
  })
}

export function batchSetResult(caseIds, result, remark, type, typeId) {
  return request({
    url: '/autotest/case/batchSetResult',
    method: 'get',
    params: { caseIds, result, remark, type, typeId }
  })
}

export function searchDetail(id, type, typeId) {
  return request({
    url: '/autotest/case/searchDetail',
    method: 'get',
    params: { id, type, typeId }
  })
}

export function uploadResultAndLog(data) {
  return request({
    url: '/autotest/case/upload/resultAndLog',
    method: 'post',
    data
  })
}

export function saveScript(caseId, script) {
  return request({
    url: '/autotest/case/saveScript',
    method: 'post',
    data: { caseId, script }
  })
}

export function localRun(baseURL, data) {
  return request({
    baseURL: baseURL,
    url: '/autotest/agent/run/script',
    method: 'post',
    data
  })
}

export function getOnTimeLog(sid) {
  return request({
    url: '/autotest/case/getOnTimeLog',
    method: 'get',
    params: { sid }
  })
}

export function updateTree(fromId, toId, fromType, toType, loc, caseFolderSortS, caseDetailSortS) {
  return request({
    url: '/autotest/case/updateTree',
    method: 'get',
    params: { fromId, toId, fromType, toType, loc, caseFolderSortS, caseDetailSortS }
  })
}

export function trueDelete(caseIds) {
  return request({
    url: '/autotest/case/delete',
    method: 'get',
    params: { caseIds }
  })
}
